package com.tiancheng.trade.order.controller.parallel;

import com.tiancheng.trade.commom.core.data.Result;
import com.tiancheng.trade.order.service.OrderParallelService;
import com.tiancheng.trade.order.vo.parallel.RefundQueryVO;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 新、老系统并行，提供给老系统兼容的退款接口
 *
 * @author kellen
 * @date 2024/6/5
 */
@Slf4j
@RestController
@RequestMapping("/api/parallel/refund")
public class RefundParallelApiController {

    @Resource
    private OrderParallelService orderParallelService;

    /**
     * 查询用户的退款数据
     * @param refundQueryVO
     * @return
     */
    @PostMapping(value = "/findByUser", consumes = MediaType.APPLICATION_JSON_VALUE)
    public Result findByUser(@RequestBody RefundQueryVO refundQueryVO) {
        if(refundQueryVO.getSize() == 0) {
            refundQueryVO.setSize(10);
        }
        return Result.success(orderParallelService.findRefundByUser(refundQueryVO));
    }


    /**
     * 查询用户的退款数据
     * @param refundQueryVO
     * @return
     */
    @PostMapping(value = "/findByUserNew", consumes = MediaType.APPLICATION_JSON_VALUE)
    public Result findRefundByUserNew(@RequestBody RefundQueryVO refundQueryVO) {
        if(refundQueryVO.getSize() == 0) {
            refundQueryVO.setSize(10);
        }
        return Result.success(orderParallelService.findRefundByUserNew(refundQueryVO));
    }
}
